use tracing_subscriber::fmt;
use tracing_subscriber::fmt::format::Writer;
use tracing_subscriber::fmt::time::FormatTime;

pub struct App;

impl App {
    pub fn init(){
        init_log()
    }
}


// 自定义日期输出
struct TimeFormatter;
impl FormatTime for TimeFormatter{
    fn format_time(&self, w: &mut Writer<'_>) -> std::fmt::Result {
        write!(w, "{}", chrono::Local::now().format("%Y-%m-%d %H:%M:%S"))
    }
}
// 初始化日志
fn init_log(){
    fmt()
        .with_max_level(tracing::Level::DEBUG)
        .with_thread_ids(true) // 显示线程id
        .with_file(true)
        .with_line_number(true) // 显示行号
        .with_timer(TimeFormatter) // 日期格式
        .init();
}